<?php
include_once "checksession.php"; 
include_once "db.php";
include_once "auth_permissions.php";
authorize("user");
if (is_numeric($_GET[callid]))
 $calls = "SELECT DISTINCT problem_type.PT_desc, computer_type.CT_desc, browser_type.BT_desc, operating_system.os_desc, Calls.* 
    FROM 
    problem_type, computer_type, browser_type, operating_system, Calls
	WHERE 
	Calls.Call_ID='$_GET[callid]' AND problem_type.PT_ID = Calls.problem_type";
$call = mysql_query($calls);
        $callsrez2 = mysql_fetch_array($call) ;  
		if ($callsrez2[os_type] != "0"){ 
		$calls .=  " AND computer_type.CT_ID = Calls.computer_type AND browser_type.BT_ID = Calls.browser_type AND operating_system.os_id = Calls.os_type";
		$call = mysql_query($calls);
		}
		$callsrez = mysql_fetch_array($call); 
		$firstname = $callsrez[first_name];
		$lastname = $callsrez[last_name];
		$othername = $callsrez[other_name];
		$othername = $callsrez[other_name];
		$pipelineuserid = $callsrez[pipeline_userid];
        $pipeline_reset = $callsrez[pipeline_reset];
		$dayphone = $callsrez[day_phone];
		$KNum = $callsrez[KNum];
		$minitial = $callsrez[m_initial];
		$bdate = $callsrez[birthdate];
		$email = $callsrez[email];
		$ssn = $callsrez[ssn];
		$PTdesc = $callsrez[PT_desc];
		$CTdesc = $callsrez[CT_desc];
		$BTdesc = $callsrez[BT_desc];
		$OSdesc = $callsrez[os_desc];
		$course = $callsrez[course];
		$semester = $callsrez[semester];
		$leftmssg = $callsrez[left_mssg];
		$problemdesc = $callsrez[problem_desc];
		$requestdate = $callsrez[request_date];
		$callclosed = $callsrez[call_closed];
		
$browsers = mysql_query("select * from browser_type where browser_type.status = '0'");
$computer = mysql_query("select * from computer_type where computer_type.status = '0'");
$problem = mysql_query("select * from problem_type where problem_type.status ='0'");
$os = mysql_query("select * from operating_system where operating_system.status ='0'");
	
//this is all a bit much.
// if ( $section != "" ) {
	// $course_info = mysql_query("select * from current_courses WHERE section = '$section'") ;
	// $courseinfo = mysql_fetch_array($course_info) ;
    // $coursenumber = $courseinfo[course_number];
    // $coursesection = $courseinfo[section];
    // $coursetitle = $courseinfo[course_title];	
	// $coursesemester = $courseinfo[semester];	
// } else {
    // $coursenumber = "-";
    // $coursesection = "-";
    // $coursetitle = "-";	
	// $coursesemester = "-";		
// }

?>
<html>
<head>
<title>Administrative Student Tracking Database</title>
<link href="meta-style.css" rel="stylesheet" type="text/css" />
</head>
<body>

<?php
include_once "topnav.php";

?>
  <?php echo "(<a href=calls_detail.php?callid=" . $_GET[callid] .">Back to Call Detail</a>)" ?>
<FORM action="update_call.php" METHOD="POST">
	<input type="hidden" name="CallID" value="<? echo $_GET[callid] ?>">
    <table width="800" border="1" cellpadding="3" cellspacing="0" align="center">
      <tr align="right" valign="bottom" bgcolor="#006699">
        <td colspan="4" align="left"><font color=white><strong>CALL INFORMATION </strong></font></td>
      </tr>
      <tr align="right" valign="bottom">
        <td valign="bottom" bgcolor="#999999"><strong>First Name:</strong></td>
        <td align="left"><input name="f_name" type="text" value="<?php echo $firstname;  ?>" size="30">
        </td>
        <td valign="bottom" bgcolor="#999999"><strong>Original Timestamp:</strong></td>
        <td align="left"><?php
	   $date = substr($requestdate,5,2)."/".substr($requestdate,8,2)."/".substr($requestdate,0,4);
	   echo $date;
	  ?>
        </td>
      </tr>
      <tr align="right" valign="bottom">
        <td bgcolor="#999999"><strong>Middle Initial:</strong></td>
        <td align="left"><input name="m_name" type="text" value="<?php echo $minitial;  ?>" size="30">
        </td>
        <td bgcolor="#999999"><strong>Left Message at Helpdesk:</strong></td>
        <td align="left"><?php
	  if ($leftmssg==1)
	  echo "Yes";
	  else if ($leftmssg==2)
      echo "No";
	  ?>
        </td>
      </tr>
      <tr align="right" valign="bottom">
        <td valign="bottom" bgcolor="#999999"><strong>Last Name:</strong></td>
        <td align="left"><input name="l_name" type="text" value="<?php echo $lastname; ?>" size="30"></td>
        <td valign="bottom" bgcolor="#999999"><strong>Computer Type:</strong></td>
        <td align="left"><select name="Platform" size=1>
            <?php
		 while($computerresults = mysql_fetch_array($computer)) {
		  if ($CTdesc == $computerresults[CT_desc])
		 echo "<option value=\"".$computerresults[CT_ID]."\" selected>".$computerresults[CT_desc]. "</option>\n";
		 else if ($callsrez[computer_type] == 0 && $computerresults[CT_ID] == 5)
		 		 echo "<option value=\"".$computerresults[CT_ID]."\" selected>".$computerresults[CT_desc]. "</option>\n";

		  else 
		 echo "<option value=\"".$computerresults[CT_ID]."\">".$computerresults[CT_desc]. "</option>\n";
	      }	  
	     ?>
          </select>
        </td>
       
      </tr>
      <tr align="right" valign="bottom">
        <td valign="bottom" bgcolor="#999999"><strong>Other Name(s):</strong></td>
        <td align="left"><input name="o_name" type="text" value="<?php echo $othername; ?>" size="30"></td>
        <td bgcolor="#999999"><strong>Browser Type:</strong></td>
        <td align="left"><select  name="browser" size=1 id="browser">
            <?php 
		  
		 while($browsersresults = mysql_fetch_array($browsers)) {
		   if ($BTdesc == $browsersresults[BT_desc])
		 echo "<option value=\"".$browsersresults[BT_ID]."\" selected>".$browsersresults[BT_desc]. "</option>\n";
		 else if ($callsrez[browser_type] == 0 && $browsersresults[BT_ID] == 29)
		 		 echo "<option value=\"".$browsersresults[BT_ID]."\" selected>".$browsersresults[BT_desc]. "</option>\n";

		  else 
		 echo "<option value=\"".$browsersresults[BT_ID]."\">".$browsersresults[BT_desc]. "</option>\n"; 
	      }
	     ?>
          </select>
        </td>
       
       
      </tr>
      <tr align="right" valign="bottom"> </tr>
      <tr align="right" valign="bottom">
        <td valign="bottom" bgcolor="#999999"><strong>Date of Birth:</strong></td>
        <td align="left"><input name="bdate" type="text" value="<?php echo $bdate ?>" size="30"></td>
        <td bgcolor="#999999"><strong>Operating System:</strong></td>
        <td align="left"><select  name="operating_system" size=1 id="operating_system">
            <?php
		 while($osresults = mysql_fetch_array($os)) {
		 if ($OSdesc == $osresults[os_desc])
		 echo "<option value=\"".$osresults[os_id]."\" selected>".$osresults[os_desc]. "</option>\n";
		 else if ($callsrez[os_type] == 0 && $osresults[os_id] == 13)
		 		 echo "<option value=\"".$osresults[os_id]."\" selected>".$osresults[os_desc]. "</option>\n";

		 else
		 echo "<option value=\"".$osresults[os_id]."\">".$osresults[os_desc]. "</option>\n";
	      }
	     ?>
        </select></td>
      </tr>
      <tr align="right" valign="bottom">
        <td valign="bottom" bgcolor="#999999"><strong>Pipeline username:</strong></td>
        <td align="left"><input name="userid" type="text" value="<?php echo $pipelineuserid; ?>" size="30"></td>
        <td valign="bottom" bgcolor="#999999"><strong>Semester:</strong></td>
        <td align="left"><input name="semester" type="text" value="<?php echo $semester; ?>" size="30"></td>
          <tr align="right" valign="bottom">
      <td bgcolor="#999999"><strong>Student ID:</strong></td>
        <td align="left"><input name="Knumber" type="text" value="<?php echo $KNum; ?>" size="30"></td>
      
        <td valign="bottom" bgcolor="#999999"><strong>Course:</strong></td>
        <td align="left"><input name="course" type="text" value="<?php echo $course; ?>" size="30"></td>
      </tr>
      <tr align="right" valign="bottom">
       <td bgcolor="#999999"><strong>Daytime Phone:</strong></td>
        <td align="left"><input name="dayphone" type="text" value="<?php echo $dayphone; ?>" size="30"></td>
        <td bgcolor="#999999"><strong></strong></td>
        <td align="left"></td>
        </tr>
         <tr align="right" valign="bottom">
         <td valign="bottom" bgcolor="#999999"><strong>Email Address:</strong></td>
        <td align="left"><input name="email" type="text" value="<?php echo $email ?>" size="30"></td>
         <td bgcolor="#999999"><strong></strong></td>
        <td align="left"></td>
        </tr>
         <tr align="right" valign="bottom">
         <td bgcolor="#999999"><strong>Problem or Question:</strong></td>
        <td align="left"><select  name="problem_type" size=1 id="problem_type">
            <?php
		 while($problemresults = mysql_fetch_array($problem)) {
		  if ($PTdesc == $problemresults[PT_desc])
		 echo "<option value=\"".$problemresults[PT_ID]."\" selected>".$problemresults[PT_desc]. "</option>\n";
		 else
		 echo "<option value=\"".$problemresults[PT_ID]."\">".$problemresults[PT_desc]. "</option>\n";
	      }
	     ?>
        </select></td>
           <td bgcolor="#999999"><strong></strong></td>
        <td align="left"></td>
      <tr>
        <td align="right" valign="bottom" bgcolor="#999999"><strong>Problem Description:</strong></td>
        <td colspan="3"><textarea name="Problem" rows=5 cols=80 wrap="soft"><?php
	  echo $problemdesc;
	  ?>
      </textarea></td>
      </tr>
      <tr>
        <td colspan="4" align="right" valign="bottom"><input type="submit" name="Submit" value="Update Info!"></td>
      </tr>
    </table>
</form>
<a href="index.php">Back to Main Menu</a>

</body>
</html>
